#include <applicationTask.h>
#include <ColorMixingTask.h>
#include <lin_device.h>
#include <adc_device.h>
#include <uart_device.h>
#include <gpio_device.h>
#include <linMasterTask.h>
#include <SoftTimerTask.h>

TaskState_t applState = TASK_STATE_INIT;
void App1TimerExpired(SoftTimer_t *timer);

#define SECTION_TIME_1    6  //ms

SoftTimer_t App1Timer = {
    .mode     = TIMER_PERIODIC_MODE,            //循环模式定时
    .interval = SECTION_TIME_1,
    .handler  = App1TimerExpired
};

RGB_t rgbTable[LED_MAX_NUM] =            //用于存储接收到的LIN帧信息进行刷新
{
    {0,0,0,0,0},    
    {0,0,0,0,0},    
    {0,0,0,0,0},    
    {0,0,0,0,0},    
    {0,0,0,0,0},         
    {0,0,0,0,0},
};

void App1TimerExpired(SoftTimer_t *timer)      
{
    CLM_SetRGBL(ROOM_TEMPERATURE, LED0, rgbTable[0].green, rgbTable[0].blue, rgbTable[0].red, rgbTable[0].level, rgbTable[0].transitionTime);
    CLM_SetRGBL(ROOM_TEMPERATURE, LED1, rgbTable[1].green, rgbTable[1].blue, rgbTable[1].red, rgbTable[1].level, rgbTable[1].transitionTime);
    CLM_SetRGBL(ROOM_TEMPERATURE, LED2, rgbTable[2].green, rgbTable[2].blue, rgbTable[2].red, rgbTable[2].level, rgbTable[2].transitionTime);
    CLM_SetRGBL(ROOM_TEMPERATURE, LED3, rgbTable[3].green, rgbTable[3].blue, rgbTable[3].red, rgbTable[3].level, rgbTable[3].transitionTime);
    CLM_SetRGBL(ROOM_TEMPERATURE, LED4, rgbTable[4].green, rgbTable[4].blue, rgbTable[4].red, rgbTable[4].level, rgbTable[4].transitionTime);
    CLM_SetRGBL(ROOM_TEMPERATURE, LED5, rgbTable[5].green, rgbTable[5].blue, rgbTable[5].red, rgbTable[5].level, rgbTable[5].transitionTime);
}

void APPL_TaskHandler(void)
{
    switch(applState)
    {
      case TASK_STATE_INIT:       //执行一次
        applState = TASK_STATE_ACTIVE;
        SoftTimer_Start(&App1Timer);    //开启一个6ms刷新一次的Timer
        break;        
      case TASK_STATE_ACTIVE:
        break;
    }
}



